
function ShowPersonFight()
{
  if (Player.tournamentpres == true)
  {
  }
  else
  {
    if (Player.active == "Player1")
    {
    Player.weptemp = Player.weaponthing;
    SetPersonX(Player.weptemp, Player.P1x);
    SetPersonY(Player.weptemp, Player.P1y);
    SetPersonFrame(Player.weptemp, 0);
    Player.Attacktemp = "main character";
    }
    else if (Player.active == "Player2")
    {
    Player.weptemp = Player2.weaponthing;
    SetPersonX(Player.weptemp, Player.P2x);
    SetPersonY(Player.weptemp, Player.P2y);
    SetPersonFrame(Player.weptemp, 0);
    Player.Attacktemp = "Player2";
    }
    else if (Player.active == "Player3")
    {
    Player.weptemp = Player3.weaponthing;
    SetPersonX(Player.weptemp, Player.P3x);
    SetPersonY(Player.weptemp, Player.P3y);
    SetPersonFrame(Player.weptemp, 0);
    Player.Attacktemp = "Player3";
    }
  
    if (Player.active == "Player1" || Player.active == "Player2" || Player.active == "Player3")
    {
    SetPersonDirection(Player.Attacktemp, 8);
    SetPersonFrame(Player.Attacktemp, 0);
    RenderMap();
    DrawPlayerStats();
    BattleName();
    FlipScreen();
    Delay(300);
    SetPersonDirection(Player.Attacktemp, 6);
    SetPersonFrame(Player.Attacktemp, 1);
    SetPersonFrame(Player.weptemp, 1);
    RenderMap();
    DrawPlayerStats();
    BattleName();
    FlipScreen();
    Delay(100);  
    SetPersonFrame(Player.Attacktemp, 2);
    SetPersonFrame(Player.weptemp, 2);
    RenderMap();
    DrawPlayerStats();
    BattleName();
    FlipScreen();
    Delay(100);  
    SetPersonFrame(Player.Attacktemp, 3);
    SetPersonFrame(Player.weptemp, 3);
    RenderMap();
    DrawPlayerStats();
    BattleName();
    FlipScreen();
    Delay(200);  
    SetPersonFrame(Player.weptemp, 0);
    SetPersonFrame(Player.Attacktemp, 0);
    }
    else
    {
    SetPersonDirection(Player.active, 2);
    RenderMap();
    DrawPlayerStats();
    BattleName();
    FlipScreen();
    Delay(50);
    SetPersonDirection(Player.active, 0);
    RenderMap();
    DrawPlayerStats();
    BattleName();
    FlipScreen();
    Delay(100);
    }
  }
}  

function Destroy(monster)
{
  if (Player.tournamentpres == true)
  {
  }
  else
  {
  SetPersonDirection(monster, 1);
  SetPersonFrame(monster, 0);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  FlipScreen();
  Delay(75);
  SetPersonFrame(monster, 1);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  FlipScreen();
  Delay(75);
  SetPersonFrame(monster, 2);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  FlipScreen();
  Delay(75);
  SetPersonFrame(monster, 3);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  FlipScreen();
  Delay(75);
  SetPersonFrame(monster, 4);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  FlipScreen();
  Delay(75);
  DestroyPerson(monster);
  }
}

function SlashFrames(file, i, j)
{
  if (Player.tournamentpres == true)
  {
  }
  else
  {
  RenderMap();
  DrawPlayerStats();
  BattleName();
  LoadImage(file + "1.png").blit(Player.tempposx - i, Player.tempposy - j);
  FlipScreen();
  Delay(50);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  LoadImage(file + "2.png").blit(Player.tempposx - i, Player.tempposy - j);
  FlipScreen();
  Delay(50);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  LoadImage(file + "3.png").blit(Player.tempposx - i, Player.tempposy - j);
  FlipScreen();
  Delay(50);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  LoadImage(file + "4.png").blit(Player.tempposx - i, Player.tempposy - j);
  FlipScreen();
  Delay(50);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  LoadImage(file + "5.png").blit(Player.tempposx - i, Player.tempposy - j);
  FlipScreen();
  Delay(50);
  }
}

function InjureFrame(Person)
{
  if (Player.tournamentpres == true)
  {
  }
  else
  {
  if (Person == "Player1")
  {
  Player.tempposx = Player.P1x;
  Player.tempposy = Player.P1y;

  SetPersonDirection("main character", 9);
  SetPersonFrame("main character", 2);
  SlashFrames("MSlash", 20, 20);
  }
  else if (Person == "Player2")
  {
  Player.tempposx = Player.P2x;
  Player.tempposy = Player.P2y;

  SetPersonDirection(Person, 9);
  SetPersonFrame(Person, 2);
  SlashFrames("MSlash", 20, 20);
  }  
  else if (Person == "Player3")
  {
  Player.tempposx = Player.P3x;
  Player.tempposy = Player.P3y;

  SetPersonDirection(Person, 9);
  SetPersonFrame(Person, 2);
  SlashFrames("MSlash", 20, 20);
  }
  else
  {
    if (Person == "Monster1")
    {
    Player.tempposx = Monster1.posx;
    Player.tempposy = Monster1.posy;
    }
    else if (Person == "Monster2")
    {
    Player.tempposx = Monster2.posx;
    Player.tempposy = Monster2.posy;
    }
    else if (Person == "Monster3")
    {
    Player.tempposx = Monster3.posx;
    Player.tempposy = Monster3.posy;
    }
    else if (Person == "Monster4")
    {
    Player.tempposx = Monster4.posx;
    Player.tempposy = Monster4.posy;
    }

  SlashFrames("Slash", 20, 20);
  }
  }
}

function DashFrames()
{
ShowPersonFight();
  if (Player.tournamentpres == true)
  {
  }
  else
  {
  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  LoadImage("DSlash1.png").blit(Player.tempposx - 20, Player.tempposy - 2);
  FlipScreen();
  Delay(50);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  LoadImage("DSlash2.png").blit(Player.tempposx - 20, Player.tempposy - 2);
  FlipScreen();
  Delay(50);
  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  LoadImage("DSlash3.png").blit(Player.tempposx - 20, Player.tempposy - 2);
  FlipScreen();
  Delay(50);
  }
}

function ChargeFrames()
{
ShowPersonFight();
  if (Player.tournamentpres == true)
  {
  }
  else
  {
  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  if (Monster4.hp > 0)
  {
  LoadImage("DSlash1.png").blit(Monster4.posx - 20, Monster4.posy - 2);
  FlipScreen();
  Delay(50);
  }

  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  if (Monster4.hp > 0)
  {
  LoadImage("DSlash2.png").blit(Monster4.posx - 20, Monster4.posy - 2);
  }
  if (Monster3.hp > 0)
  {
  LoadImage("DSlash1.png").blit(Monster3.posx - 20, Monster3.posy - 2);
  }
  FlipScreen();
  Delay(50);

  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  if (Monster4.hp > 0)
  {
  LoadImage("DSlash3.png").blit(Monster4.posx - 20, Monster4.posy - 2);
  }
  if (Monster3.hp > 0)
  {
  LoadImage("DSlash2.png").blit(Monster3.posx - 20, Monster3.posy - 2);
  }
  if (Monster2.hp > 0)
  {
  LoadImage("DSlash1.png").blit(Monster2.posx - 20, Monster2.posy - 2);
  }
  FlipScreen();
  Delay(50);

  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  if (Monster3.hp > 0)
  {
  LoadImage("DSlash3.png").blit(Monster3.posx - 20, Monster3.posy - 2);
  }
  if (Monster2.hp > 0)
  {
  LoadImage("DSlash2.png").blit(Monster2.posx - 20, Monster2.posy - 2);
  }
  if (Monster1.hp > 0)
  {
  LoadImage("DSlash1.png").blit(Monster1.posx - 20, Monster1.posy - 2);
  }
  FlipScreen();
  Delay(50);

  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  if (Monster2.hp > 0)
  {
  LoadImage("DSlash3.png").blit(Monster2.posx - 20, Monster2.posy - 2);
  }
  if (Monster1.hp > 0)
  {
  LoadImage("DSlash2.png").blit(Monster1.posx - 20, Monster1.posy - 2);
  }
  FlipScreen();
  Delay(50);

  RenderMap();
  DrawPlayerStats();
  BattleName();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  if (Monster1.hp > 0)
  {
  LoadImage("DSlash3.png").blit(Monster1.posx - 20, Monster1.posy - 2);
  }
  FlipScreen();
  Delay(50);
  }
}

function SwordDrainFrames()
{
ShowPersonFight();
SlashFrames("DrSlash", 20, 20);
}

function UpdatePlayers()
{
  if (Player.tournamentpres == true)
  {
  }
  else
  {
  if (Player.hp <= 0)
  {
    SetPersonDirection("main character", 9);
    SetPersonFrame("main character", 0);
  }
  else if (Player.hp <= Player.maxhp/4)
  {
    SetPersonDirection("main character", 9);
    SetPersonFrame("main character", 1);
  }  
  else
  {
    SetPersonDirection("main character", 6);
    SetPersonFrame("main character", 0);
  }

  if (Player2.pres == true)
  {
    if (Player2.hp <= 0)
    {
      SetPersonDirection("Player2", 9);
      SetPersonFrame("Player2", 0);
    }
    else if (Player2.hp <= Player2.maxhp/4)
    {
      SetPersonDirection("Player2", 9);
      SetPersonFrame("Player2", 1);
    }  
    else
    {
      SetPersonDirection("Player2", 6);
      SetPersonFrame("Player2", 0);
    }
  }

  if (Player3.pres == true)
  {
    if (Player3.hp <= 0)
    {
      SetPersonDirection("Player3", 9);
      SetPersonFrame("Player3", 0);
    }
    else if (Player3.hp <= Player3.maxhp/4)
    {
      SetPersonDirection("Player3", 9);
      SetPersonFrame("Player3", 1);
    }
    else
    {
      SetPersonDirection("Player3", 6);
      SetPersonFrame("Player3", 0);
    }
  }
  }
}
